package com.hl.controller;

import com.hl.domain.Articletype;
import com.hl.service.ArticleTypeService;
import com.hl.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Hr
 * @date 2024/9/5 21:59
 */
@RestController
@RequestMapping("/articleType")
public class ArticleTypeController {

    @Autowired
    private ArticleTypeService articleTypeService;

    //根据id查某种类型
    @GetMapping("/selectByPrimaryKey")
    public R selectByPrimaryKey(Long id){
        Articletype articletype = articleTypeService.selectByPrimaryKey(id);
        return articletype != null ? R.success(articletype) : R.fail(articletype);
    }

    //查询所有类型
    @GetMapping("/findAllArticleType")
    public R findAllArticleType(){
        List<Articletype> allArticleType = articleTypeService.findAllArticleType();
        return allArticleType != null ? R.success(allArticleType) : R.fail(allArticleType);
    }
}
